﻿#ifndef DATASTORAGE_H
#define DATASTORAGE_H

#include <QObject>
#include <QFile>
#include <QDataStream>
#include <QReadWriteLock>

class CDataStorage : public QObject
{
    Q_OBJECT
public:
    explicit CDataStorage(QObject *parent = 0);
    void AddToListData(const QByteArray &);           //往存储数据的QList<QByteArray>添加数据
    inline qint32 Count(){return countCmd;}           //返回数据长度
    QByteArrayList *GetListData(qint32 index,qint32 len);    //返回指定位置开始长为len的数据包
    bool SetSaveFile(QString);                        //设置存储文件名
    bool SaveData();                                  //存储文件
private:
    QByteArrayList      listData;                     //存储数据的QList<QByteArray>
    QStringList         listTag;                      //存储附加信息的QList<QString>
    qint32              countCmd;                     //数据长度
    QByteArrayList      *listOut;                     //返回的的QList<QByteArray>数据
    QString             saveFileName;                 //存储文件名
    QReadWriteLock      rwLock;                       //读取互斥锁

signals:

public slots:
};
extern CDataStorage *cmdStorage;                     //cmd数据存储体
#endif // DATASTORAGE_H
